package com.smartwebx.fr.bean;

import java.io.IOException;
import java.util.List;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;

public class SmartTable {
	private String tableData;
	private String dataType;
	private String id;

	public void setTableData(String tableData) {
		this.tableData = tableData;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getDataType() {
		return dataType;
	}

	public void setDataType(String dataType) {
		this.dataType = dataType;
	}

	public Object getTableData() throws IOException {
		ObjectMapper mapper = new ObjectMapper();
		Object result = null;
		if ("table".equals(dataType)) {
			result = mapper.readValue(tableData, new TypeReference<List<List<String>>>() {
			});
		} else if ("freeTable".equals(dataType)) {
			result = mapper.readValue(tableData, new TypeReference<FreeTable>() {
			});
		}
		return result;
	}
}